package com.lrd.snapshotorder.service.rule;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * ruleMap：由配置类创建完成
 */
@Service
public class RuleService implements IRuleService {

    @Resource
    @Qualifier("ruleMap")
    private Map<String, IRule> ruleMap;

    @Override
    public IRule findRule(String scene) {
        if (!ruleMap.containsKey(scene)) {
            throw new RuntimeException("unknown scene: " + scene);
        }
        return ruleMap.get(scene);
    }
}
